﻿
/**
 * IDS (Iterative deepening depth-first search)
 */
public class IDS : DLS
{
    /**
     * Constructor
     */
    public IDS(string fn) : base(fn)
    {}


    /**
    * Iterative depening depth-first search
    */
    public System.Collections.Generic.List<Node> iterativeDeepeningSearch(string initialState, string goalState)
    {
        /** limit for iterative deepening  */
        const int DEPTHLIMIT = 1000;

        /** 
         * for depth <- 0 to infinity do
         */
        for (int depth = 0; depth <= DEPTHLIMIT; ++depth) {
            /** result <- DEPTH-LIMITED-SEARCH(problem, depth) */
            System.Collections.Generic.List<Node> result = depthLimitedSearch(initialState, goalState, depth);
            /** if result != cutoff then return result */
            if (result != null) { return result; }
        }
        
        return null;
    }





} // class IDS
